<template>
  <div id="app">
    <div id="nav"></div>
    <transition :name="transitionName">
      <router-view />
    </transition>
  </div>
</template>

<script>
export default {
  data(){
    return {
    transitionName:""
    };
  },
  computed: {},
  watch: {
      $route(to, from) {
        // console.log(11);
     //如果to索引大于from索引,判断为前进状态,反之则为后退状态
     if(to.meta.index > from.meta.index){
     //设置动画名称
    //  console.log('left');
      this.transitionName = 'slide-left';
     }else{
    //  console.log('right');

      this.transitionName = 'slide-right';
     }
    }
  },
  methods: {},
  created() {},
  mounted() {},
  destroyed() {},
  activated() {},
};
</script>
<style lang="scss">
#app {
  // font-family: Avenir, Helvetica, Arial, sans-serif;
  font-family: myFirstFont;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  height: 100%;
}
body,
html {
  height: 100%;
  font-family: myFirstFont;
}
@font-face {
  font-family: myFirstFont;
  src: url(./assets/ziti.ttf);
}

#nav {
  // padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
.slide-left{
  display: inline-flex;
}
.slide-left-enter {
 opacity: 0;
 transform: translateX(100%);
}
.slide-left-enter-active {
 transition: 0.5s;
}
.slide-left-enter-to {
 opacity: 1;
 transform: translateX(0);
}
.slide-left-leave{
  transform: translateX(0);
  opacity: 1;
}
.slide-left-leave-active {
 transition:  0.5s;
}

.slide-left-leave-active-to {
  opacity: 0;
  transform: translateX(-100%);
}




.slide-right{
  display: inline-flex;
}
.slide-right-enter {
 opacity: 0;
 transform: translateX(-100%);
}
.slide-right-enter-active {
 transition: 0.5s;
}
.slide-right-enter-to {
 opacity: 1;
 transform: translateX(0);
}
.slide-right-leave{
  transform: translateX(0);
  opacity: 1;
}
.slide-right-leave-active {
 transition:  0.5s;
}
.slide-right-leave-active-to {
  opacity: 0;
  transform: translateX(100%);
}
</style>
